package com.baway.biliclitent.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.baway.biliclitent.R;
import com.baway.biliclitent.model.RecommendBean;
import com.bumptech.glide.Glide;

import java.util.List;

/**
 * 作者：朱振江 on 2017/3/10 0010 20:54
 * 邮箱：zzjdys@Gmail.com
 * 类用途:
 */


public class item_livedadapter extends BaseAdapter {
    private Context mContext;
    private List<RecommendBean.ResultBean.BodyBean> mList;

    public item_livedadapter(Context context) {
        mContext = context;
    }

    public void  setData(List<RecommendBean.ResultBean.BodyBean> list) {
        this.mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewhord v;
        if (convertView==null)
        {
            v=new viewhord();
            convertView=View.inflate(mContext, R.layout.home_recommend_item,null);
            v.video_preview= (ImageView) convertView.findViewById(R.id.video_preview);
            v.video_title= (TextView) convertView.findViewById(R.id.video_title);
            v.item_live_up= (TextView) convertView.findViewById(R.id.item_live_up);
            v.item_live_online= (TextView) convertView.findViewById(R.id.item_live_online);
            v.layout_live= (RelativeLayout) convertView.findViewById(R.id.layout_live);
            v.layout_video= (LinearLayout) convertView.findViewById(R.id.layout_video);
            v.layout_bangumi= (RelativeLayout) convertView.findViewById(R.id.layout_bangumi);
            convertView.setTag(v);
        }else 
        {
            v= (viewhord) convertView.getTag();
        }
        v.layout_video.setVisibility(View.GONE);
        v.layout_live.setVisibility(View.VISIBLE);
        v.layout_bangumi.setVisibility(View.GONE);
        v.video_title.setText(mList.get(position).getTitle());
        v.item_live_up.setText(mList.get(position).getUp());
        v.item_live_online.setText(mList.get(position).getOnline());
        Glide.with(mContext).load(mList.get(position).getCover()).into(v.video_preview);
        return convertView;
    }
    
    class viewhord 
    {
        ImageView video_preview;
        TextView item_live_up,item_live_online,video_title;
        RelativeLayout layout_bangumi,layout_live;//番剧//直播//
        LinearLayout layout_video;//普通
    } 
    
    
}
